﻿using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Web;

namespace HashFoo.Rest.ServerTests.FakeHttpStack
{
    public class FakeHttpRequest : HttpRequestBase
    {
        string[] _acceptTypes = new string[] { };
        Stream _inputStream;

        public FakeHttpRequest SetAcceptTypes(string[] types)
        {
            _acceptTypes = types;
            return this;
        }

        public override string[] AcceptTypes
        {
            get
            {
                return _acceptTypes;
            }
        }

        public override string ContentType { get; set; }

        public void SetBody(string data, Stream stream)
        {
            _inputStream = stream;
            var writer = new StreamWriter(_inputStream);
            writer.Write(data);
            writer.Flush();

            if (_inputStream.CanSeek) _inputStream.Seek(0, SeekOrigin.Begin);
        }

        public override System.IO.Stream InputStream
        {
            get
            {
                return _inputStream;
            }
        }
    }
}